<?php

namespace ali;

use AlibabaCloud\SDK\Dysmsapi\V20170525\Dysmsapi;
use Darabonba\OpenApi\Models\Config;

/**
 * 阿里接口客户端
 */
class Client
{
    public static $config = [];

    /**
     * 生成客户端,用于调用阿里接口
     * @return Dysmsapi
     */
    public static function createClient()
    {
        $config = self::getConfig();
        $configApi = new Config([
            // 您的AccessKey ID
            "accessKeyId" => $config['accessKeyId'],
            // 您的AccessKey Secret
            "accessKeySecret" => $config['accessKeySecret'],
        ]);
        // 访问的域名
        $configApi->endpoint = "dysmsapi.aliyuncs.com";
        return new Dysmsapi($configApi);
    }

    // 获取阿里配置
    public static function getConfig()
    {
        self::$config = \config('ali_qmh');
        return self::$config;
    }

    // 获取短信配置
    public static function getConfigSms($key='sms') {
        $config = self::getConfig();
        return $config[$key];
    }
}